翻訳と辞書
Words near each other
・ "O" Is for Outlaw
・ "O"-Jung.Ban.Hap.
・ "Ode-to-Napoleon" hexachord
・ "Oh Yeah!" Live
・ "Our Contemporary" regional art exhibition (Leningrad, 1975)
・ "P" Is for Peril
・ "Pimpernel" Smith
・ "Polish death camp" controversy
・ "Pro knigi" ("About books")
・ "Prosopa" Greek Television Awards
・ "Pussy Cats" Starring the Walkmen
・ "Q" Is for Quarry
・ "R" Is for Ricochet
・ "R" The King (2016 film)
・ "Rags" Ragland
・ ! (album)
・ ! (disambiguation)
・ !!
・ !!!
・ !!! (album)
・ !!Destroy-Oh-Boy!!
・ !Action Pact!
・ !Arriba! La Pachanga
・ !Hero
・ !Hero (album)
・ !Kung language
・ !Oka Tokat
・ !PAUS3
・ !T.O.O.H.!
・ !Women Art Revolution


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

default argument : ウィキペディア英語版
default argument

In computer programming, a default argument is an argument to a function that a programmer is not required to specify.
In most programming languages, functions may take one or more arguments. Usually, each argument must be specified in full (this is the case in the C programming language〔http://elec.uq.edu.au/~comp2303/Leslie_C_ref/CPLUSPLUS/CONCEPT/fundefault.html〕). Later languages (for example, in C++) allow the programmer to specify default arguments that always have a value, even if one is not specified when calling the function.
== Default arguments in C++ ==

Consider the following function declaration:

int my_func(int a, int b, int c=12);

This function takes three arguments, of which the last one has a default of twelve. The programmer may call this function in two ways:

result = my_func(1, 2, 3);


result = my_func(1, 2);

In the first case the value for the argument called ''c'' is specified as normal. In the second case, the argument is omitted, and the default value of ''12'' will be used instead.
There is no means to know if the argument has been specified by the caller or if the default value was used.
The above-mentioned method is especially useful when one wants to set default criteria so that the function can be called with or without parameters.
Consider the following:

void printToScreen(istream &input = cin)

The function call:

printToScreen();

will by default print input from the keyboard to the screen. As this is the most commonly used behaviour it makes sense not to specify

printToScreen(cin);

on the other hand any parameter of type istream can now be passed to the same function and the function will print to screen from the source specified as the parameter to the function.
Consider:

printToScreen(fileName);

where fileName is a file that has been opened to read via ifstream's open function call.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「default argument」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.